<template>

  <ex_select_auto ref="main" :option="option" filterable remote :remoteQuery="remoteQueryFun" :url="url" :value="value"
    :reserve-keyword="true" default-first-option :urlParams="urlParams" :dependentId="customerId" v-bind="$attrs"
    v-on="$listeners" />
</template>
<script>
import Vue from 'vue'
import role_system_mixin from '@/mixin/role_system_mixin';

export default {
  mixins: [role_system_mixin,],

  data() {
    return {
      url: '',
    }
  },
  props: {
    value: null,
    customerId: {
      type: [Number, String],
      default: null,
    },
    option: {
      type: [Object, Function],
      default: () => {
        return function (it) {
          return { label: Vue.prototype.$formatNameCode(it.skuName, it.skuBarcode), value: it['id'] }
        }
      }
    },
  },

  created() {
    if (this.isOmsSystem) {
      this.url = "/mms-api/sku/MmsSkuInfoRpc/selectByMmsSkuInfo.json"
    } else if (this.isCustomerSystem) {
      this.url = "/mms-api/client/MmsSkuInfoClientRpc/selectByMmsSkuInfo.json"
    } else if (this.isWmsSystem) {
      this.url = "/wms-api/sku/WmsSkuInfoRpc/selectSkuPage.json"
    }
  },
  methods: {
    urlParams() {
      let params = {}
      if (this.customerId) params.customerId = this.customerId
      return params
    },
    remoteQueryFun(query) {
      return {
        skuBarcodeOrSkuName: query.trim(),
        keyword: query.trim(),
      }
    },



  },
}
</script>
